40923235 cp2020

  • Home
    • Site Map
    • reveal
    • blog
  • 首頁
  • HW1
    • UNIT 1
      • Strategies for Learning學習策略
      • What You Need to Know About the Course您需要了解的課程內容
      • About these Materials 關於這些材料
      • Metacognition元認知
      • Metacognition in Action行動中的元認知
    • UNIT2
      • Introduction簡介
      • Functions of Computers  Input  Output  Storage  and Processing計算機功能  輸入  輸出  存儲和處理
      • Hardware硬件
      • Software軟件
      • Fireware固件
      • Componentization  Standardization組件化  標準化
      • Connection Interfaces and Cables連接接口和電纜
  • HW2
  • HW3
    • Chacrater input字符輸入
      • input strings types int輸入字符串類型int
      • Discussion討論區-1
      • User input in Python使用Python的用戶輸入
      • Manipulating strings a few ways處理字符串幾種方法
    • Odd Or Even奇數或偶數
      • Exercise 2 and solution練習2和解決方案
      • Discussion討論區-2
      • Modular arithmetic the modulus operator模塊化算術模運算符
      • Conditionals有條件的
      • Checking for equality and comparators in general檢查是否相等以及一般的比較器
    • List Less Than Ten列出少於十
      • Exercise 3 and Solution練習3和解決方案
      • Discussion討論區-3
      • Lists清單
      • More Conditionals更多條件
  • 心得
Discussion討論區-1 << Previous Next >> Manipulating strings a few ways處理字符串幾種方法

User input in Python使用Python的用戶輸入

To get user input in Python (3), the command you use is input(). Store the result in a variable, and use it to your heart’s content. Remember that the result you get from the user will be a string, even if they enter a number.

For example,

name = input("Give me your name: ")
print("Your name is " + name)

What this will print in the terminal (or the shell, whatever you are running Python in) will be:

>>> Give me your name: Michele
Your name is Michele

What happens at the end of input() is that it waits for the user to type something and press ENTER. Only after the user presses ENTER does the program continue.

要在Python(3)中獲得用戶輸入,你使用的命令是input()。將結果存儲在變量中,並將其用於你的內心。請記住,即使用戶輸入數字,你從用戶那裡得到的結果也將是字符串。

例如,

name = input("Give me your name: ")
print("Your name is " + name)

這將在終端(或外殼,無論您在其中運行Python的是什麼)中顯示的內容是:

>>> Give me your name: Michele
Your name is Michele

最後發生的input()是,它等待用戶鍵入內容並按Enter。僅在用戶按下ENTER之後,程序才會繼續。


Discussion討論區-1 << Previous Next >> Manipulating strings a few ways處理字符串幾種方法

Copyright © All rights reserved | This template is made with by Colorlib